<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>适用校区单价配置</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="margin-top:7px;float:right;margin-left: 10px;"
       href="{:url('course/course_manage')}">
        返回课程管理</a>

</div>
<div style="padding:15px;">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">校区</label>
            <div class="layui-input-inline">
                <input type="text" value="{$campus}" readonly autocomplete="off"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单价</label>
            <div class="layui-input-inline">
                <input type="text" name="price" required lay-verify="required" value="{$configure.price}" placeholder="输入单价" autocomplete="off"  class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">元/课时</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">课时数</label>
            <div class="layui-input-inline">
                <input type="text" name="class_num" required lay-verify="required" value="{$configure.class_num}" placeholder="输入课时数" autocomplete="off"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">课时时长</label>
            <div class="layui-input-inline">
                <input type="text" name="class_time" required lay-verify="required" value="{$configure.class_time}" placeholder="输入课时时长" autocomplete="off"  class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">分钟</div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value="{$id}" class="layui-input">
                <input class="layui-btn" lay-submit lay-filter="form" value="保存" readonly>
            </div>
        </div>
    </form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}

<script>
    //JavaScript代码区域
    layui.use(['element', 'form', 'layer', 'laydate'], function () {
        var $ = layui.$,
            element = layui.element,
            form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(form)', function (data) {
            var field = data.field;
            var isLoad;
            $.ajax({
                url: "{:url('course/configure')}",
                method: "post",
                data: field,
                beforeSend: function () {
                    isLoad = layer.load(0, {
                        shade: false
                    }); //0代表加载的风格，支持0-2
                },
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.code === 0) {
                        setTimeout(function () {
                            location.href = '{:url("course/course_manage")}';
                        }, 2000);
                    }
                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });
            return false;
        });
    });
</script>